$fileSave="d:\log\"+(Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")+".txt"

if (!(Test-Path "d:\log\log\c\d")) {
    # New-Item -ItemType Directory -Path $fileSave -Force
    New-Item -ItemType Directory -Path "d:\log\log\c\d" -Force
}

$win=0

for($i=1;$i -le 10;$i++) {

    sleep(1)

    $punch1 = Get-Random -Minimum 1 -Maximum 3
    $punch2 = Get-Random -Minimum 1 -Maximum 3
    $outStr=""

    if ($punch1 -eq $punch2) {
        $outStr="The "+$i+" time, draw match."
    } elseif ($punch1 -lt $punch2) {
        $outStr = "The "+$i+" time, punch2 wins."
    } else {
        $win++
        $outStr = "The "+$i+" time, punch1 wins."
    }
    $outStr |Out-File -FilePath $fileSave -Encoding utf8 -Append
}

$winrate = "$win" + "%"
"punch1 win rate is "+$winrate |Out-File -FilePath $fileSave -Encoding utf8 -Append